Go to the first, previous, next, last section, table of contents.

Interface

The player interface is how actual players interact with the game. It need not be graphical or even particularly interactive, in fact it could even be a network server-style interface! However, this section will concentrate on the construction of interactive graphical interfaces.

Interface Architecture

An interface is always compiled in, so it has complete access to the game state. However, if your version of Xconq has any networking support, the interface should not modify kernel structures directly, but should instead use kernel routines. The kernel routines will forward any state modifications to all other programs participating in a game, so that everybody's state remains consistent.

A working interface must provide some level of capability in each of these areas:

The file skelconq.c in the kernel directory is a good example of a minimum working interface.

Don't let interfaces ever set kernel object values directly, always go through calls that can be "siphoned" for networking.

Main Program

The interface provides main() for Xconq; this allows maximum flexibility in adapting to different environments. In a sense, the kernel is a large library that the interface calls to do game-related operations.

There is a standard set of calls that need to be made during initialization. The set changes from time to time, so the following extract from `skelconq' should not be taken as definitive:

    init_library_path(NULL);
    clear_game_modules();
    init_data_structures();
    parse_command_line(argc, argv, general_options);
    load_all_modules();
    check_game_validity();
    parse_command_line(argc, argv, variant_options);
    set_variants_from_options();
    parse_command_line(argc, argv, player_options);
    set_players_from_options();
    parse_command_line(argc, argv, leftover_options);
    make_trial_assignments();
    calculate_globals();
    run_synth_methods();
    final_init();
    assign_players_to_sides();
    init_displays();
    init_signal_handlers();
    run_game(0);

Note that this sequence is only straight-through for a simple command line option program; if you have one or more game setup dialogs, then you choose which to call based on how the players have progressed through the dialogs. The decision points more-or-less correspond to the different parse_command_line calls in the example. You may also need to interleave some interface-specific calls; for instance, if you want to display side emblems in a player/side selection dialog, then you will need to arrange for the emblem images to be loaded and displayable, rather than doing it as part of opening displays.

Once a game is underway, the interface is basically self-contained, needing only to call run_game periodically to keep the game moving along. run_game takes one argument which can be -1, 0, or 1. If 1, then one unit gets to do one action, then the routine returns. If 0, the calculations are gone through, but no units can act. If -1, then all possible units will move before run_game returns. This last case is not recommended for interactive programs, since moving all units in a large game may take a very long time; several minutes sometimes, and run_game may not necessarily call back to the interface very often.

Startup Options

Although there are many different ways to get a game started, you have three main categories of functionality to support: 1) selection of the game to play, 2) setting of variants, and 3) selection of players. For command-line-using programs, the file cmdline.c need only be linked in to provide all of this functionality. For graphical interfaces, you will need to design appropriate dialogs. This can be a lot of work, exacerbated by the fact that these dialogs will be the first things that new Xconq players see, and will therefore shape their opinions about the quality of the interface and of the game.

[more detail about what has to be in dialogs?]

Interface code should check all player specs, not proceed with initialization until these are all valid.

Both standard and nonstandard variants should vanish from or be grayed out in dialog boxes if irrelevant to a selected game.

Progress Indication

Some synthesis methods are very slow, and become even slower when creating large games, so the kernel will announce a slow process, provide regular updates, and signal when the process is done. The interface should display this in some useful way. In general, progress should always be displayed, although one could postpone displaying anything until after the first progress update, calculate an estimated time to completion, and not display anything if that estimate is for less than a few seconds. However, this is probably unnecessary.

Feedback and Control

The interface should provide visible feedback for every successful unit action initiated directly by the player, but it need not do so for failures, unless they are serious. It is better to prevent nonsensical input, for instance by disabling menus and control panel items. Simple interfaces such as for character terminals will have to relax these rules somewhat.

Interfaces should enable/disable display of lighting conditions.

Play Commands

There is no single correct way to support direct player control over units. Although keyboard commands and mouse clicks are obvious choices, it would be very cool to allow a pen or mouse to sketch a movement plan, or to be able to give verbal orders...

There is a common set of ASCII keyboard commands that are recommended for all Xconq interfaces that use a keyboard. These are defined in kernel/cmd.def. If you use these, Xconq players will be able to switch platforms and still use familiar commands. cmd.def defines a single character, a command name, a help string, and a function name, always in the form do_*. However, cmd.def does not specify arguments, return types, or behavior of those functions, so each interface must still define its own command lookup and calling conventions.

If you include cmd.def, you must then provide definitions for all the functions that it mentions. You should also provide some sort of feedback for commands that are not implemented, or that are not useful. Players who are used to another interface will expect to be able to type the same commands, and can get very confused if the familiar commands neither work nor complain about not working. One way to fill in defaults for functions that you don't want to do yet is to use macros ahead of the inclusion of cmd.def:

#define do_quit default_empty_do
#define do_save default_empty_do
...

#include "cmd.def"

default_empty_do()
{
	notify(a_side, "Command not implemented in this interface");
}

Prefixed number args should almost always be repetitions.

If already fully fueled, refuel commands should come back immediately.

A quit cmd can always take a player out of the game, but player may have to agree to resign. Player can also declare willingness to quit or draw without actually doing so, then resolution requires that everybody agree. If quitting but others continuing on, also have option of being a spectator. Could have notion of "leaving game without declaring entire game a draw" for some players. Allow for a timeout and default vote in case some voters have disappeared mysteriously. Must never force a player to stay in. Add a notion of login/logout so a side can be inactive but untouchable, possibly freezes entire game if a side is inactive. 1. if one player or no scoring confirm, then shut player down if one player, then shut game down 2. if side is considered a sure win (how to tell? is effectively a win condition then) or all sides willing to draw confirm, take side out, declare a draw, shut player down 3. if all sides willing to quit take entire game down 4. ask about resigning - if yes, resign, close display, keep game running if no, ask if willing to quit and/or draw, send msg to other sides Kernel support limited to must_resign_to_quit(side), similar tests.

Error Handling

The interface must provide implementations of these error-handling functions:

Textual Displays

Text can take a long time to read, and can be difficult to provide in multiple human languages. (What, you thought only English speakers played Xconq? Think again!) Therefore, text displays in the interfaces should be as minimal as possible, and derive from strings supplied in the game design, since they can be altered without rebuilding the entire program.

(Xconq is not, at the moment, completely localizable, but that is a design goal.)

Display Update

Usually the interface's display is controlled by the player, but when run_game is executing, it will frequently change the state of an object in a way that needs to be reflected in the display immediately. Examples include units leaving or entering a cell, sides losing or winning, and so forth. The interface must define a set of callbacks that will be invoked by the kernel.

Each of these routines has a flag indicating whether the change may be buffered or not. To ensure that buffered data is actually onscreen, the kernel may call flush_display_buffers(), which the interface must define.

These may or may not be called on reasonable sides, so the interface should always check first that side actually exists and has an active display. [If side has a "remote" display, then interface has to forward?? No, because remote copy of game is synchronized and does own update_xxx calls more-or-less simultaneously]

Note that this is as much as the kernel interests itself in displays. Map, list, etc drawing and redrawing are under the direct control of the interface code.

Unix-hosted versions must provide void close_displays() for signal handlers to call.

Types of Windows and Panels

Xconq is best with a window-style interface, either tiled or overlapping. Overlapping is more flexible, but also more complicated for players. In the following discussion, "window" will refer to a logically unified part of the display, which can be either a distinct window or merely a panel embedded in some larger window.

The centerpiece window should be a map display. This will be the most-used window, since it will typically display more useful information than any other window. This means that it must also exhibit very good performance.

When a game starts up, the map display should be centered on one of the player's units, preferably one close to the center of all the player's units.

Another recommended window is a list of all the sides and where they stand in both the current turn and in the game as a whole. Each side's entry should include its name, a progress bar or other doneness indicator, and room for all the scores and scorekeepers that apply to that side.

If possible, you should also implement some kind of "face" or group of faces/expressions for a side, so get a barbarian's face to repn a side instead of generic. Could have interface generate remarks/balloons if face clicked on, perhaps a reason for feelings, slogan, citation of agreement or broken agreement, etc. Need 5 faces for hostile, unfavorable, neutral, favorable, friendly/trusting.

Since the rules for when sides are in or out of a game can be complicated, it is important to indicate each side's status clearly. The most important bit is the in or out part. You should indicate sides that are out of the game by dimming or graying, and by removing any indicators of game play, such as the side's progress display. Keep in mind that you may need to list the sides before or after the actual game.

To indicate that a side lost, you can draw a line through it. To indicate that it won, you can draw laurels or other decoration all around.

The action progress bar for each side tells all the players about how turn is progressing, and should reflect the aggregate of unit states. Here are some suggested appearances:

Technically, the progress bars for other sides gives away information about how strong they are and what they're doing. However, the interface benefit of players knowing how fast each of them is moving and when the turn is likely to be over is tremendous.

Imaging

Imaging is the process of drawing pictorial representations. Not every interface needs it. For instance the curses interface is limited to drawing two ASCII characters for each cell, and its imaging code just has to choose which two to draw. However, full-color bitmapped displays need more attention to the process of getting an image onscreen.

If a requested image cannot be found, the interface should synthesize a substitute. For instance, the Mac interface uses the binary encoding of the terrain's index to make up a pattern for tiling; not pretty, but each type is distinguishable, and the lack of an image for a terrain type is very obvious.

Even if the interface can synthesize a substitute, it should still warn that the images could not be found. In the case of terrain, where solid colors may be used, the interface should warn if neither color nor image is available.

No graphical icon should be drawn smaller than about 8x8, unless it's a text character drawn in two contrasting colors.

Interfaces should cache optimal displays for each mag, not search for best image each time.

Could allow 1-n "display variants" for all images, and for each orientation of border and connection.

Imaging variations can be randomly selected by UI, but must be maintained so redraws are consistent.

Allow the 64 bord/conn combos as single images, also advantage that all will be drawn at once.

Draw partial cells around edges of a window, to indicate that the world continues on in that direction.

Interface needs to draw only the terrain (but including connections and borders) in edge cells.

Could draw grid by blitting large light pattern over world, do by inverting so is easy to turn on/off. Do grids by changing hex size only in unpatterned color?

Draw large hexagon or rect in unseen-color after clearing window to bg stipple (if unseen-color different). Polygon should be inside area covered by edge hexes, so unseen area more obvious. Make large unseen-pattern that includes question marks?

If picture not defined for a game, use some sort of nondescript image instead of leaving blank. (small "no picture available" for instance, like in yearbooks)

To display night, overlay a black mask on the terrain, both cell and linear. World is totally lit if dimensions < half of world circumference and all six corners of hexagon have same lighting. If world totally dark, can draw darkening mask once for entire map.

To display elevation, use deep blue -> light gray -> dark brown progression, and/or contour lines.

If multiple connection or border types, the interface should draw them offset slightly from each other.

Animation

In addition to basic imaging, you can also support requests for the playing of animations or movies.

The kernel just calls schedule_movie to create one, and then play_movies when it is time to run all the movies that have been scheduled. It is up to the interface to do something useful. Note that the kernel is not aware of the movies' timing, so it is better not to call run_game until all the movies have finished playing. (Yes, this would be a good future enhancement!)

Several types of movies are predefined, so your interface can recognize them specially. These include movie_miss, movie_hit, movie_death, which are scheduled for the appropriate outcomes of combat.

Game Designer Tools

An interface is not required to provide any sort of online designing tools, or even to provide a way to enable the special design privileges. Nevertheless, minimal tools can be very helpful, and you will often find that they are helpful in debugging the rest of the interface, since you can use them to construct test cases at any time.

A basic set of design tools should include a way to enable and disable designing for at least one side, a command to create units of a given type, and some sort of tool to set the terrain type at a given location. A full set would include "painting" tools for all area layers, including geographical features, materials, weather, side views, and so forth - about a dozen in all.

A least one level of undo for designer actions is very desirable, although it may be hard to implement. A useful rule for layers is to save a layer's previous state at the beginning of each painting or other modification action, when the mouse button first goes down.

The designer will often want to save only the part of the game being worked on, for instance only the units or only the terrain. The "save game" action should give designers a choice about what to save. For units particularly, the designer should be able to save only some properties of units. The most basic properties are type, location, side, and name/number. The unit id should not be saved by default, but should have its own option (not clear why).

Note that because game modules are textual and can be moved easily from one system to another, it is entirely possible to use one Xconq (perhaps on a Mac) to design games to be played on a Unix box under X11, or vice versa. This means that the interface should always save the designer's work as an ordinary text file if possible, so as not to require any further manipulation.

Likewise, any image design tools should have some sort of option to save as text, so that the imagery for a game design can be used on every platform that the design can.

Porting and Multiple Interfaces

In theory, it is possible to compile multiple interfaces into a single Xconq program, but this would be hard at best. They would have to be multiplexed appropriately and not conflict anywhere in the address space. Sometimes this is intrinsically impossible; how could you compile the Mac and X interfaces into the same program, and would the result be a Mac application, a Unix program, or what?

Useful Displays

This is a collection of minor but useful displays that might be worth adding to an interface.

A "mouse over" is a line or two of text that describes what the mouse/pointer is currently pointing at, and which updates automatically as the player moves the pointer around. This is better for high-bandwidth interfaces, since there may be a lot of updating involved. The volume can be reduced slightly by only redisplaying when the mouse moves, or, better, when what is being looked at changes. This is probably best done by recalculating the line of text and then comparing it to what has been drawn already, although if the display is very fast, you may not save much in drawing time. One approx 40-char lines covers basic info, such as terrain type and unit type; more detail may require multiple long lines.

Useful Options

A "follow action" option scrolls the screen to where the last event happened, such as combat. [etc]

Debugging Aids

Xconq is complicated enough that you can't expect to throw together a complete working interface over the weekend. Therefore, you should build some debugging aids into the interface. You can ifdef with the flag DEBUGGING so as to ensure the code won't be in final versions.

Display unit id if closeups, toplines, etc, if debugging is on.

Guidelines and Suggestions

Although as the interface builder, you are free to make it work in any way you like, there are a number of basic things you should do. Some of these are general user interface principles, others are specific to Xconq, usually based on experiences with the existing interfaces. Applying some of these guidelines will require judicious balancing between consistency with the different version of Xconq and consistency with the system you're porting to.

[following items should be better organized, moved in with relevant sections]

Draw single selected unit in a stack larger.

Draw single selected occupant in UR corner next to transport, when at mags that show both transport and occs.

There should always be some sort of "what's happening now" display so player doesn't wonder about apparently dead machine.

Image tool should report which type of resource is generating a given image, so can find which to hack on (report for selected image only).

Interfaces should ensure stability of display choices if random possibilities, so need to cache local decisions about appearance of units if multiple images to choose from, choice of text messages, etc.

Rules of Interaction: 1. Player can get to any unit in any mode. 2. Any player can prevent a turn from completing(/progressing?), unless a hard real limit is encountered. 3. All players see each others' general move/activity state, modes, etc. 4. Players can "nudge" each other. 5. Real time limits can be set for sides, turns, and games, both by players and by scenarios.

Player should be able to click on a desired unit or image, and effectively say "take this", either grabs directly or else composes a task to approach and capture.

Unit closeups should be laid out individually for each type, too much variability to make a single format reasonable.

Add option where game design can specify use or avoidance of masks with unit icons.

Player could escape a loss by saving a game, then discarding save. Mplayers could register suspicion when player saves then quits - "You're not trying to cheat, are you?" - but can't prevent this.

All interfaces should be able to bring up an "Instructions" window that informs player(s) about the current game, includes xrefs to all game design info. Restrict help to generic and interface info only.

Graph display should graphing of various useful values, such as amounts of units and materials over time, attitudes of sides, combat, etc. Maximal is timeline for all sides and units, usually too elaborate but allow tracking movement for some "important" units. Note that move actions may be recorded anyway.

Make specialized dialog for agreements, put name on top, then scrolling list of terms, then signers, then random bits (public/secret, etc). Use for proposals also, so allow for "tentative" signers, desired signers who have not looked at agreement. Be able to display truth of each term, but need test to know when a side can know the truth of a term?

Interfaces should have a "wake up dummy" button that can be used by players who have finished their turn, to prod other players not yet done.

Commands that are irrelevant for a game ought to be grayed out in help displays, and error messages should identify as completely invalid (or just not do anything, a la grayed Mac menu shortcuts).

Should be able to drag out a route and have unit follow it (user input of a complete task sequence).

Hack formatting so that variable-width fonts usually work reasonably.

Add xref buttons to various windows to go to other relevant windows and focus in.

The current turn or date should be displayed prominently and be visible somewhere by default.

Add some high-level verbs as commands ("assault Berlin", "bomb London until destroyed").

Don't draw outline boxes at mags that would let them get outside the hex.

If dating view data, allow it to gray out rather than disappear entirely. Could even have a "fade time" for unit images...

Even if display is textual, use red text (and other colors) to indicate dangerous conditions.

Next/prev unit controls should change map focus, even if screen unaffected.

In general, ability to "select" a unit implies ability to examine, but not control. Control implies ability to select, however.

Use a builtin color matching a color name if possible, otherwise use the imc definition.

Connections may need to be drawn differently in each of the two hexes they involve, such as straits connecting to a sea. (what is this supposed to mean?)

If cell cramped for space, show only one material type at a time, require redraw to show amounts of a different type.

Draw time remaining both digitally and as hourglass, for all time limits in effect.

Could tie map to follow a specified unit (or to flip there quickly a la SimAnt).

Have a separate message window from notices, allow broadcasting w/o specific msg command? (a "talk" window)

Redraw hexes exposed when a unit with a legend moves. Truncate or move legend if would overlap some other unit/legend.

Put limits on the number of windows of each type, set up so will reuse windows, except for ones that are "staked down".

Fix border removal so inter-hex boundary pixels are cleaned up also.

Need a specialized window or display to check on current scores (showing actual situation vs what's still needed). (Show both scorekeepers actually in force, as well as the others.) Side display could also display scores relevant to that side.

Every unit plan display should have a place to record notes and general info about the unit, add a slot to units also. Use in scenarios.

Need a command for when a player can explicitly change the self-unit.

Players should be able to rename any named object. The interface should also provide a button or control to run any namer that might be available to the unit.

Be able to select unit number display indep of unit name display, and feature name display indep of unit names.

Don't draw things that xform to 0 pixel areas, only draw the most important things if 1-4 pixels or so.

If time/effort to do action is > length of game, then interface can disable that action permanently.

Use moving bar or gray under black to indicate reserve/asleep units.

Autoscrolling should always position so that each adjacent cell to a unit also shows *entire* adjacent cells, all around.


Go to the first, previous, next, last section, table of contents.